#include "StringUtil.h"


StringUtil::StringUtil()
{
}

StringUtil::~StringUtil()
{
}

string StringUtil::trim(string inputStr){
	if (inputStr.empty()){
		return "";
	}
	inputStr.erase(0, inputStr.find_first_not_of(' '));
	inputStr.erase(inputStr.find_last_not_of(' ')+1);
	return inputStr;
}

vector<string> StringUtil::split(string inputStr, string Separators){
	vector<string> Rslt;
	std::string::size_type pos1, pos2;
	pos2 = inputStr.find(Separators);
	pos1 = 0;
	while (string::npos != pos2){
		Rslt.push_back(inputStr.substr(pos1, pos2 - pos1));
		pos1 = pos2 + Separators.size();
		pos2 = inputStr.find(Separators, pos1);
	}
	if (pos1 != inputStr.length())	{
		Rslt.push_back(inputStr.substr(pos1));
	}
	return Rslt;
}